package com.phkj.qdh.ui.adapter.employeenode

import android.widget.CheckBox
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.phkj.qdh.R
import com.phkj.qdh.utils.node.BaseNode
import com.phkj.qdh.utils.node.BaseNodeProvider
import com.phkj.qdh.utils.node.BaseViewHolder

class EmployeeContentProvider : BaseNodeProvider() {
    override val itemViewType: Int
        get() = 2
    override val layoutId: Int
        get() = R.layout.item_employee_select_content

    override fun convert(helper: BaseViewHolder, item: BaseNode) {
        val data = item as EmployeeNode
        val cb = helper.getView<CheckBox>(R.id.cb)
        helper.setText(R.id.tv_name, item.tree.userNamePhone)
        cb.setOnCheckedChangeListener(null)
        cb.isChecked = item.isSelected
//        cb.setOnCheckedChangeListener { btn, b ->
//            when (b) {
//                true -> {
//
//                    item.isSelected = true
//                }
//
//                false -> {
//                    item.isSelected = false
//                }
//            }
//
//        }

        helper.getView<RelativeLayout>(R.id.ll).setOnClickListener {
            item.isSelected = ! item.isSelected
            cb.isChecked = item.isSelected
        }
    }
}